package com.momo.hotel.service.impl;

import com.momo.hotel.dao.mapping.TbUserMapper;
import com.momo.hotel.dao.mapping.ext.TbUserMapperExt;
import com.momo.hotel.dao.pojo.TbUser;
import com.momo.hotel.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @version 1.0.0
 * @auther Snake
 * @date 2019/7/1 17:30
 */
@Service
public class UserServiceImpl implements UserService {

    @Resource
    TbUserMapper userMapper;

    @Resource
    TbUserMapperExt userMapperExt;

    @Override
    public boolean addUser(TbUser user) {
        int reSet = userMapperExt.addUser(user);
        if (reSet>0){
            return true;
        }
        return false;
    }

    @Override
    public boolean uploadUser(TbUser tbUser) {
        Integer integer = userMapperExt.uploadUser(tbUser);
        if (integer>0){
            return true;
        }
        return false;
    }



    @Override
    public boolean loginUser(TbUser user) {
        TbUser tbUser = userMapperExt.loginUser(user);
        if (tbUser!=null){
            return true;
        }
        return false;
    }

    @Override
    public boolean checkUsername(TbUser user) {
        List<TbUser> list = userMapperExt.checkUsername(user);
        if (list.size()>0){
            return false;
        }
        return true;
    }

    @Override
    public TbUser loginUserByUserName(String username) {
        return userMapperExt.loginUserByUserName(username);
    }


}
